/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.worlds.object;

import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.worlds.WorldsException;

/**
 *
 * @author Jacob
 */
public class PlayerStats extends GameObject{
    private ArrayList<GameObject> values = new ArrayList<GameObject>();
    public PlayerStats() throws WorldsException
    {
        super("PlayerStats");
    }
    public ArrayList<GameObject> getValues()
    {
        return values;
    }
    public Object get(String key)
    {
        for(GameObject obj : values)
        {
            if(obj.toString().equals(key))
                try {
                return obj.getProp("Value");
            } catch (WorldsException ex) {
                ex.printStackTrace();
            }
        }
        return null;
    }
    @Override
    public void addChild(GameObject c) throws WorldsException
    {
        super.addChild(c);
        if(c instanceof TextValue || c instanceof IntegerValue || c instanceof Vec2DValue)
        {
            if(!values.contains(c))
                values.add(c);
        }
    }
    @Override
    public void removeChild(GameObject c)
    {
        super.removeChild(c);
        if(c instanceof TextValue || c instanceof IntegerValue || c instanceof Vec2DValue)
        {
            values.remove(c);
        }
    }
}
